using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for BaseUserPage
/// </summary>
public abstract class BaseUserPage : BasePage
{

    protected override void OnLoad(EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                currentUserId = int.Parse(Request.QueryString["Id"]);
            }
            catch (FormatException)
            {
            }
            catch (ArgumentNullException)
            {
            }
        }
        base.OnLoad(e);
    }

    private int currentUserId;
    public int CurrentUserId
    {
        get { return currentUserId; }
    }

    private Acms.Bll.User currentUser;
    public Acms.Bll.User CurrentUser
    {
        get
        {
            if (currentUser == null && currentUserId > 0)
            {
                currentUser = Acms.Bll.User.GetById(currentUserId);
            }
            return currentUser;
        }
    }

    protected override object SaveViewState()
    {
        ViewState["CurrentUserId"] = currentUserId;
        return base.SaveViewState();
    }

    protected override void LoadViewState(object savedState)
    {
        base.LoadViewState(savedState);
        if (ViewState["CurrentUserId"] is int)
        {
            currentUserId = (int)ViewState["CurrentUserId"];
        }
    }
	
}
